<template>
    <div>
        <el-header height="auto">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item :to="{ path: '/Main/index' }">首页</el-breadcrumb-item>
                <el-breadcrumb-item>
                    <a>编辑</a>
                </el-breadcrumb-item>
                <el-breadcrumb-item>文本编辑</el-breadcrumb-item>
            </el-breadcrumb>
            <el-dropdown placement="bottom">
                <span class="el-dropdown-link">
                    <img src="../../assets/img/default.jpg" alt />
                </span>
                <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item @click.native="goToIndex">首页</el-dropdown-item>
                    <el-dropdown-item @click.native="LogOUt">退出</el-dropdown-item>
                </el-dropdown-menu>
            </el-dropdown>
        </el-header>
        <main class="edit">
            <template>
                <quill-editor
                    v-model="content"
                    ref="myQuillEditor"
                    :options="editorOption"
                    @blur="onEditorBlur($event)"
                    @focus="onEditorFocus($event)"
                    @ready="onEditorReady($event)"
                ></quill-editor>
            </template>
        </main>
    </div>
</template>
<script>
import Quill from "quill";

export default {
    data() {
        return {
            content: "<h2>文本编辑</h2>",  // 默认显示内容
            editorOption: { }
        };
    },
    // 如果需要手动控制数据同步，父组件需要显式地处理 changed事件
    methods: {
        /* 富文本编辑器事件 */
        onEditorBlur(quill) { },
        onEditorFocus(quill) { },
        onEditorReady(quill) { },
        onEditorChange({ quill, html, text }) {
            this.content = html;
        },
        // 跳转至首页
        goToIndex() {
            this.$router.push({ path: "/Main/index" });
        },
        // 退出登录
        LogOUt() {
            this.$router.push({ path: "/" });
        }
    },
    computed: {
        editor() {
            return this.$refs.myQuillEditor.quill;
        }
    },
    mounted() { }
};
</script>
<style scoped>
.edit {
    padding: 30px;
}
.quill-editor {
    height: 350px;
}
</style>